home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre3.z / postgre3 / src / lib / H / nodes / mnodes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.2 KB  |  130 lines

  1. /*
  2.  * mnodes.h --
  3.  *    POSTGRES memory context node definitions.
  4.  *
  5.  * Identification:
  6.  *    $Header: /private/postgres/src/lib/H/nodes/RCS/mnodes.h,v 1.8 1991/09/30 10:13:15 glass Exp $
  7.  */
  8.  
  9. #ifndef    MNodesIncluded
  10. #define MNodesIncluded    1    /* Include this file only once */
  11.  
  12. #include "tmp/c.h"
  13.  
  14. #include "utils/memutils.h"
  15. #include "tmp/fstack.h"
  16.  
  17. #include "nodes/nodes.h"
  18.  
  19. /*
  20.  * MemoryContext --
  21.  *    A logical context in which memory allocations occur.
  22.  *
  23.  * The types of memory contexts can be thought of as members of the
  24.  * following inheritance hierarchy with properties summarized below.
  25.  *
  26.  *            Node
  27.  *            |
  28.  *        MemoryContext___
  29.  *        /        \
  30.  *    GlobalMemory    PortalMemoryContext
  31.  *            /        \
  32.  *    PortalVariableMemory    PortalHeapMemory
  33.  *
  34.  *            Flushed at    Flushed at    Checkpoints
  35.  *            Transaction    Portal
  36.  *            Commit        Close
  37.  *
  38.  * GlobalMemory            n        n        n
  39.  * PortalVariableMemory        n        y        n
  40.  * PortalHeapMemory        y        y        y
  41.  */
  42.  
  43. typedef struct MemoryContextMethodsData {
  44.     Pointer    (*alloc)();
  45. /* BAD PROTOTYPE DELETED -- glass */
  46. /*        ARGS((classObj(MemoryContext) context, uint32 length));*/
  47.     void    (*free_p)(); /* need to use free as a #define, so can't use free */
  48. /* BAD PROTOTYPE DELETED -- glass */
  49. /*        ARGS((classObj(MemoryContext) context, Pointer pointer));*/
  50.     Pointer    (*realloc)();
  51. /* BAD PROTOTYPE DELETED -- glass */
  52. /*        ARGS((
  53.             classObj(MemoryContext) context,
  54.             Pointer pointer,
  55.             uint32 length
  56.         ));*/
  57.     String    (*getName)();
  58. /* BAD PROTOTYPE DELETED -- glass */
  59. /*   ARGS((classObj(MemoryContext) context)); */
  60. #if    0
  61. /*
  62.  * Do these make sense as general methods?  Probably not, but I am not
  63.  * sure, yet. -hirohama
  64.  */
  65.     void    (*reset) ARGS((classObj(MemoryContext) context));
  66.     void    (*destroy) ARGS((classObj(MemoryContext) context));
  67. #endif
  68.     void    (*dump)();
  69. /* BAD PROTOTYPE DELETED -- glass */    
  70.         /* ARGS((classObj(MemoryContext) context));*/
  71. } MemoryContextMethodsData;
  72.  
  73. typedef MemoryContextMethodsData    *MemoryContextMethods;
  74.  
  75.  
  76.  
  77. class (MemoryContext) public (Node) {
  78. #define MemoryContextDefs \
  79.     inherits0(Node); \
  80.     MemoryContextMethods    method
  81. /* private: */
  82.     MemoryContextDefs;
  83. /* protected: */
  84. #define LispNodeIncrementRef(_node_)    (((LispNode)_node_)->refCount += 1)
  85. #define LispNodeDecrementRef(_node_)    (((LispNode)_node_)->refCount -= 1)
  86. #define LispNodeGetRefCount(_node_)    (((LispNode)_node_)->refCount)
  87. #define LispNodeSetRefCount(_node_,_cnt_)    \
  88.     (LispNodeGetRefCount(_node_) = _cnt_)
  89. /* public: */
  90.     /* XXX fill me in */
  91. };
  92.  
  93. class (GlobalMemory) public (MemoryContext) {
  94.     inherits1(MemoryContext);
  95.     AllocSetData    setData;    /* set of allocated items */
  96.     String        name;
  97.     OrderedElemData    elemData;    /* member of set of GlobalMemory */
  98.     /* XXX fill me in */
  99. };
  100.  
  101. class (PortalMemoryContext) public (MemoryContext) {
  102. #define PortalMemoryContextDefs \
  103.     inherits1(MemoryContext)
  104. /* private: */
  105.     PortalMemoryContextDefs;
  106. /* protected: */
  107. /* public: */
  108.     /* XXX fill me in */
  109. };
  110.  
  111. class (PortalVariableMemory) public (PortalMemoryContext) {
  112.     inherits2(PortalMemoryContext);
  113.     AllocSetData    setData;
  114. };
  115.  
  116. class (PortalHeapMemory) public (PortalMemoryContext) {
  117.     inherits2(PortalMemoryContext);
  118.     Pointer        block;
  119.     FixedStackData    stackData;
  120. };
  121.  
  122. /*
  123.  * MemoryContextIsValid --
  124.  *    True iff memory context is valid.
  125.  */
  126. #define MemoryContextIsValid(context) \
  127.     ((bool) IsA(context,MemoryContext))
  128.  
  129. #endif    /* !defined(MNodesIncluded) */
  130.